<div id="container" class="clear">
	<div id="left">
	<h2>我发布的代码(<?php echo $codeNum; ?>)</h2>
		<?php if(count($mycodes)){ ?>
		<ul class="mb10 mt10" id="mycodes">
			<?php foreach($mycodes as $mycode){ ?>
			<li class="bdotted pb10 mb10">
			<p class="fwb"><a href="<?php echo url::site('code/detail/'.$mycode->id); ?>"><?php echo $mycode->title; ?></a></p>
			<p class="fr fs12"><?php echo date::get_latest_timespan(date::timespan($mycode->pubdate)); ?></p>
			<p class="fs12 gray"><?php echo '<a href="'.url::site('code/lan/'.$mycode->lan).'">'.$mycode->lan.'</a>';$cmtNum = $mycode->comments->count(); echo ' | '.$cmtNum.'条评论';$fav = $mycode->users->count(); echo ' | '.$fav.'人收藏'; ?> </p>
			</li>
			<?php } ?>
		</ul>
		<div class="fr mb20 fs12" id="mycodesPagination"><?php echo $codePagination; ?></div>
		<?php }else{ ?>
			<p class="mb30">暂无相关内容</p>
		<?php } ?>

		<h2 class="clearfix">我收藏的代码(<?php echo $favNum; ?>)</h2>
		<?php if(count($favcodes)){ ?>
		<ul class="mt10" id="myfavs">
			<?php foreach($favcodes as $favcode){ ?>
			<li class="bdotted pb10 mb10">
				<div class="fl mr10">
				<a href="<?php echo url::site('user/view/'.$favcode->user->id); ?>"><img title="<?php echo $favcode->user->username; ?>" width="36" height="36" src="<?php echo gravatar::get($favcode->user->email,36); ?>" /></a>
				</div>
			<p class="fwb"><a href="<?php echo url::site('code/detail/'.$favcode->id); ?>"><?php echo $favcode->title; ?></a></p>
			<p class="fr fs12"><?php echo date::get_latest_timespan(date::timespan($favcode->pubdate)); ?></p>
			<p class="fs12 gray"><?php echo '<a href="'.url::site('code/lan/'.$favcode->lan).'">'.$favcode->lan.'</a>';$cmtNum = $favcode->comments->count(); echo ' | '.$cmtNum.'条评论';$fav = $favcode->users->count(); echo ' | '.$fav.'人收藏'; ?> </p>
			</li>
			<?php } ?>
		</ul>
		<div class="fr mb20 fs12" id="myfavsPagination"><?php echo $favPagination; ?></div>
		<?php }else{ ?>
			<p class="mb30">暂无相关内容</p>
		<?php } ?>

		<h2 class="clearfix">我关注的人发布的代码</h2>
		<?php if((count($followcodes))){?>
		<ul class="mt10">
			<?php foreach($followcodes as $followcode){ ?>
			<li class="bdotted pb10 mb10">
				<div class="fl mr10">
				<a href="<?php echo url::site('user/view/'.$followcode->user->id); ?>"><img width="36" height="36" src="<?php echo gravatar::get($followcode->user->email,36); ?>" /></a>
				</div>
			<p class="fwb"><a href="<?php echo url::site('code/detail/'.$followcode->id); ?>"><?php echo $followcode->title; ?></a></p>
			<p class="fr fs12"><?php echo date::get_latest_timespan(date::timespan($followcode->pubdate)); ?></p>
			<p class="fs12 gray"><?php echo '<a href="'.url::site('code/lan/'.$followcode->lan).'">'.$followcode->lan.'</a>';$cmtNum = $followcode->comments->count();if($cmtNum) echo ' | '.$cmtNum.'条评论';$fav = $followcode->users->count();if($fav) echo ' | '.$fav.'人收藏'; ?> </p>
			</li>
			<?php } ?>
		</ul>
		<?php }else{ ?>
			<p class="mb30">暂无相关内容</p>
		<?php } ?>

	</div>

	<div id="right">
		<div class="clear">
		<p class="bdotted pb5 mb10 fs14">我关注这些人</p>
		<?php if(count($following)){ ?>
		<ul class="flli clear mb20">
		<?php foreach($following as $follower){ ?>
		<li class="pr5"><a href="<?php echo url::site('user/view/'.$follower->id) ?>"><img title="<?php echo $follower->username; ?>" src="<?php echo gravatar::get($follower->email); ?>" /></a></li>
		<?php } ?>
		</ul>
		<?php }else{ ?>
		<p class="gray mb20">你没有关注任何人</p>
		<?php } ?>
		</div>

		<div class="clear">
		<p class="bdotted pb5 mb10 fs14">这些人关注我</p>
		<?php if(count($beingfollowed)){ ?>
		<ul class="flli clear mb20">
		<?php foreach($beingfollowed as $follower){ ?>
		<li class="pr5"><a href="<?php echo url::site('user/view/'.$follower->id) ?>"><img title="<?php echo $follower->username; ?>" src="<?php echo gravatar::get($follower->email); ?>" /></a></li>
		<?php } ?>
		</ul>
		<?php }else{ ?>
		<p class="gray">暂时没有人关注你</p>
		<?php } ?>
		</div>
	</div>
	
</div>

<script type="text/javascript">
$('#mycodesPagination p.pagination a').live('click',(function(e){
	e.preventDefault();
	$loading = '<img src="<?php echo url::base().'media/img/loading.gif'; ?>" style="margin-left:-30px;margin-top:10px;float:left"></img>';
	$('#mycodesPagination').prepend($loading);
	$list = '';
	$.getJSON($(this).attr('href'),function(data){
		for(i=0;i<data.msg.length-1;i++){
			$str = [
				'<li class="bdotted pb10 mb10">',
				'<p class="fwb"><a href="<?php echo url::site('code/detail/'); ?>'+data.msg[i].id+'">'+data.msg[i].title+'</a></p>',
				'<p class="fr fs12">'+data.msg[i].pubdate+'</p>',
				'<p class="fs12 gray"><a href="<?php echo url::site('lan/');?>'+data.msg[i].lan+'">'+data.msg[i].lan+'</a> | '+data.msg[i].cmtNum+'条评论 | '+data.msg[i].favNum+'人收藏',
				'</li>'
			];
			$list += $str.join('');
		}
		$pagination = data.msg[data.msg.length-1];
		$('#mycodes').children().remove();
		$('#mycodesPagination').children().remove();
		$('#mycodes').html($list);
		$('#mycodesPagination').html($pagination);
	});
	
})
);

$('#myfavsPagination p.pagination a').live('click',(function(e){
	e.preventDefault();
	$loading = '<img src="<?php echo url::base().'media/img/loading.gif'; ?>" style="margin-left:-30px;margin-top:10px;float:left"></img>';
	$('#myfavsPagination').prepend($loading);
	$list = '';
	$.getJSON($(this).attr('href'),function(data){
		for(i=0;i<data.msg.length-1;i++){
			$str = [
				'<li class="bdotted pb10 mb10">',
				'<p class="fwb"><a href="<?php echo url::site('code/detail/'); ?>'+data.msg[i].id+'">'+data.msg[i].title+'</a></p>',
				'<p class="fr fs12">'+data.msg[i].pubdate+'</p>',
				'<p class="fs12 gray"><a href="<?php echo url::site('lan/');?>'+data.msg[i].lan+'">'+data.msg[i].lan+'</a> | '+data.msg[i].cmtNum+'条评论 | '+data.msg[i].favNum+'人收藏',
				'</li>'
			];
			$list += $str.join('');
		}
		$pagination = data.msg[data.msg.length-1];
		$('#myfavs').children().remove();
		$('#myfavsPagination').children().remove();
		$('#myfavs').html($list);
		$('#myfavsPagination').html($pagination);
	});
	
})
);
</script>
